home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1996 June
/
MACPOWER-1996-06.ISO.7z
/
MACPOWER-1996-06.ISO
/
AMUG
/
PROGRAMING_7
/
Fat Module
/
Fat Module ト
/
GraphicsModule_main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-20
|
4KB
|
129 lines
/*
GraphicsModule_main.c
Apple and Think C Implementation of 'ADgm' screen saver code resource.
This file provides a generic interface for writing a After Darkェ graphics module.
The function "main" is called by After Dark and passed four parameters:
storage: A Handle to memory you have allocated.
blankRgn: A region covering all screens.
message: A value indicating which function to call.
params: A pointer to a structure containing useful information.
To use it, write the five routines:
OSErr DoInitialize(Handle *storage, RgnHandle blankRgn, GMParamBlockPtr params);
OSErr DoClose(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
OSErr DoBlank(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
OSErr DoDrawFrame(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params);
OSErr DoSetUp(RgnHandle blankRgn, short message, GMParamBlockPtr params);
For more information, consult the programmer's section of the manual.
By Patrick Beard and Bruce Burkhalter and Colin Glassey
ゥ1989,1990,1991 Berkeley Systems, Inc.
------
I added the following for use with Metrowerks C++ 1.2.2:
- Support for Metrowerks A4 globals.
- Prototypes.
- A __procinfo definition.
Note that Berkeley Systems has no responsibility for this altered version of
GraphicsModule_main.c. Use it at your own risk.
Robert Geisler, 8/20/95
*/
#include <QuickDraw.h>
#include "GraphicsModule_Types.h"
#ifdef THINK_C
/* allows use of Global vars with Think C */
#include <SetUpA4.h>
#define OpenGlobals() RememberA0(); SetUpA4();
#define CloseGlobals() RestoreA4();
#endif
#ifdef __MWERKS__
#include <A4Stuff.h>
ProcInfoType __procinfo=kPascalStackBased
|RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
|STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Handle *)))
|STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(RgnHandle)))
|STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
|STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(GMParamBlockPtr)));
OSErr DoInitialize(Handle *storage, RgnHandle blankRgn, GMParamBlockPtr params),
DoBlank(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params),
DoDrawFrame(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params),
DoClose(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params),
DoSelected(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params),
DoSetUp(RgnHandle blankRgn, short message, GMParamBlockPtr params);
#endif
/* entry point into graphics module */
pascal OSErr
main(Handle *storage, RgnHandle blankRgn, short message, GMParamBlockPtr params)
/* storage allocated by graphics module. */
/* region to do all drawing in. */
/* the action to take */
/* parameters & services for controlling graphics module */
{
OSErr err=noErr;
#ifdef __MWERKS__
long oldA4=SetCurrentA4();
#endif
#ifdef THINK_C
/* set up globals for strings etc. only for THINK C */
OpenGlobals();
#endif
/* dispatch message to appropriate routine. */
switch(message) {
case Initialize:
err=DoInitialize(storage, blankRgn, params);
break;
case Close:
err=DoClose(*storage, blankRgn, params);
break;
case Blank:
err=DoBlank(*storage, blankRgn, params);
break;
case DrawFrame:
err=DoDrawFrame(*storage, blankRgn, params);
break;
/* Bouncing Ball does not handle the next two messages. */
case ModuleSelected:
/*err=DoSelected(*storage, blankRgn, params);*/
break;
case DoAbout:
/*err=DoAbout(*storage, blankRgn, params);*/
break;
default: /* user may have hit a button */
if(message>=ButtonMessage) {
/* handle the button */
err=DoSetUp(blankRgn, message, params);
} /* end if */
break;
} /* end switch */
#ifdef THINK_C
CloseGlobals();
#endif
#ifdef __MWERKS__
SetA4(oldA4);
#endif
return err;
}